package com.git.smp.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.codec.digest.Md5Crypt;
import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.sl.draw.binding.CTColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Color;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFHyperlink;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.git.smp.cache.DataDictionaryCache;
import com.git.smp.cache.SmpSystemCache;
import com.git.smp.cache.SmpUserCache;
import com.git.smp.core.PageRequest;
import com.git.smp.core.ResponseMessage;
import com.git.smp.dao.ApplyServerMapper;
import com.git.smp.dao.EnvironmentInfoMapper;
import com.git.smp.dao.SmpConsumeMapper;
import com.git.smp.dao.SmpFieldMapper;
import com.git.smp.dao.SmpServiceHisMapper;
import com.git.smp.dao.smpFieldHisMapper;
import com.git.smp.dao.SmpServiceMapper;
import com.git.smp.dao.SmpSystemCallMapper;
import com.git.smp.dao.SmpSystemMapper;
import com.git.smp.dao.SmpUserRoleMapper;
import com.git.smp.entity.ApplyField;
import com.git.smp.entity.ApplyServer;
import com.git.smp.entity.ApplyServerExtend;
import com.git.smp.entity.CallListInfo;
import com.git.smp.entity.ConsumeInfo;
import com.git.smp.entity.IntercatedSystemList;
import com.git.smp.entity.SmpConsume;
import com.git.smp.entity.SmpConsumeKey;
import com.git.smp.entity.SmpField;
import com.git.smp.entity.SmpFieldKey;
import com.git.smp.entity.SmpFile;
import com.git.smp.entity.SmpInterfaceList;
import com.git.smp.entity.SmpService;
import com.git.smp.entity.SmpServiceDetails;
import com.git.smp.entity.SmpServiceExtend;
import com.git.smp.entity.SmpServiceHis;
import com.git.smp.entity.SmpServiceHisExtend;
import com.git.smp.entity.SmpServiceKey;
import com.git.smp.entity.SmpSystem;
import com.git.smp.entity.SmpSystemCall;
import com.git.smp.entity.SmpSystemCallExtend;
import com.git.smp.entity.SmpUserRole;
import com.git.smp.entity.SystemNums;
import com.git.smp.entity.VueData;
import com.git.smp.entity.smpFieldHis;
import com.git.smp.utils.ObjectUtil;
import com.git.smp.utils.StringUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jcraft.jsch.jce.MD5;

@RestController
@RequestMapping("/service")
public class SmpServiceController {

	Logger logger = LoggerFactory.getLogger(SmpServiceController.class);

	@Autowired
	SmpServiceMapper smpServiceMapper;

	@Autowired
	SmpFieldMapper smpFieldMapper;

	@Autowired
	SmpConsumeMapper smpConsumeMapper;

	@Autowired
	SmpSystemMapper smpSystemMapper;

	@Autowired
	SmpSystemCallMapper smpSystemCallMapper;

	@Autowired
	EnvironmentInfoMapper environmentInfoMapper;

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private HttpServletResponse response;

	@Autowired
	private DataDictionaryCache dataDictionaryCache;

	@Autowired
	SmpUserRoleMapper userRoleMapper;

	@Autowired
	SmpServiceHisMapper smpServiceHisMapper;

	@Autowired
	smpFieldHisMapper smpFieldHisMapper;

	@Autowired
	ApplyServerMapper applyServerMapper;

	@Autowired
	smpFieldHisMapper fieldHisMapper;

	@Autowired
	SmpSystemCache systemCache;
	
	@Value("${templateversion}")
	private String templateversion;
	// 分页查询服务信息
	@RequestMapping("/getTemplateversion")
	public ResponseMessage<String> getTemplateversion() {
		ResponseMessage<String> responseMessage = new ResponseMessage<String>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
	responseMessage.setExtend(templateversion);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 分页查询服务信息
	@RequestMapping("/getServiceByPage")
	public ResponseMessage<PageInfo<SmpServiceExtend>> getServiceByPage(
			@RequestBody PageRequest<SmpServiceExtend> pageRequest) {
		ResponseMessage<PageInfo<SmpServiceExtend>> responseMessage = new ResponseMessage<PageInfo<SmpServiceExtend>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		SmpServiceExtend smpServiceExtend = pageRequest.getBody();

		// 判断当前用户是否为农商行用户
		String userName = request.getHeader("userName");

		SmpUserRole smpUserRole = new SmpUserRole();
		smpUserRole.setRoleId("1007");
		smpUserRole.setUserName(userName);

		int count = userRoleMapper.selectCount(smpUserRole);
		if (count > 0) {
			smpServiceExtend.setOutShow("01");
		}
		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		List<SmpServiceExtend> listSmpService = smpServiceMapper.getServiceByPage(smpServiceExtend);
		if (listSmpService == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询所有服务信息失败！");
		}
		PageInfo<SmpServiceExtend> pageInfo = new PageInfo<SmpServiceExtend>(listSmpService, pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 导出服务信息
	 * 
	 * @param pageRequest
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/exportAllService")
	public void exportAllService(@RequestBody PageRequest<SmpServiceExtend> pageRequest) throws IOException {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		SmpServiceExtend smpServiceExtend = pageRequest.getBody();

		List<SmpServiceExtend> listSmpService = smpServiceMapper.getServiceByPage(smpServiceExtend);

		response.setContentType("application/octct-stream");
		buildService(response.getOutputStream(), listSmpService);
	}

	/**
	 * 导出服务信息
	 * 
	 * @param pageRequest
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/exportSystem")
	public void exportSystem(@RequestBody SmpSystem smpSystem) throws IOException {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		SmpServiceExtend smpServiceExtend = new SmpServiceExtend();
		smpServiceExtend.setSystemNo(smpSystem.getSystemNo());

		List<SmpServiceExtend> listSmpService = smpServiceMapper.getServiceByPage(smpServiceExtend);

		SmpSystem smpSystem1 = smpSystemMapper.getSystemInfo(smpSystem.getSystemNo());

		response.setContentType("application/octct-stream");
		buildSystem(response.getOutputStream(), listSmpService, smpSystem1);
	}

	/**
	 * 导出服务信息
	 * 
	 * @param pageRequest
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/exportService")
	public void exportService(@RequestBody List<SmpServiceExtend> listSmpService) throws IOException {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
		response.setContentType("application/octct-stream");
		buildService(response.getOutputStream(), listSmpService);
	}

	/**
	 * 导出服务信息
	 * 
	 * @param pageRequest
	 * @return
	 */
	public void buildService(OutputStream out, List<SmpServiceExtend> listSmpService) {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		//cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		

		XSSFColor  xssfColor = new XSSFColor(new java.awt.Color(216,228,188));
		cellStyle3.setFillForegroundColor(xssfColor);
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		
		XSSFCellStyle cellStyle1_4 = workbook.createCellStyle();
		cellStyle1_4.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_4.setFont(font);
		
		// cellStyle1_2.setFont(font);

		// 获取工作表名称是Index
		Sheet sheet = workbook.createSheet("目录");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 10 * 256);
		sheet.setColumnWidth(3, 10 * 256);
		sheet.setColumnWidth(4, 40 * 256);
		sheet.setColumnWidth(1, 20 * 256);
		sheet.setColumnWidth(7, 20 * 256);
		sheet.setColumnWidth(8, 40 * 256);
		sheet.setColumnWidth(10, 12 * 256);
		// sheet.setColumnWidth(9, 40*256);

		Row row = sheet.createRow(0);
		Cell cell = row.createCell(0);
		cell.setCellValue("版 本 号：");
		cell.setCellStyle(cellStyle1_4);
		
		cell = row.createCell(1);
		cell.setCellValue(templateversion);
		//cell.setCellStyle(cellStyle1_4);

		 row = sheet.createRow(1);

		String[] title = new String[] { "系统编号", "系统名称", "机构号", "交易码", "交易名称", "报文协议", "报文编码", "ESB测试地址", "测试URL",
				"外部可见","http请求方法", "操作类型", "新交易码" };
		for (int i = 0; i < title.length; i++) {
			 cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < listSmpService.size(); i++) {
			row = sheet.createRow(i + 2);
			Cell systemNoCell = row.createCell(0);
			systemNoCell.setCellStyle(cellStyle1);
			systemNoCell.setCellValue(listSmpService.get(i).getSystemNo());
			// String systemName =
			// smpSystemMapper.getSystemInfo(listSmpService.get(i).getSystemNo()).getSystemName();
			Cell systemNameCell = row.createCell(1);
			systemNameCell.setCellStyle(cellStyle1);
			systemNameCell.setCellValue(SmpSystemCache.getSystemName(listSmpService.get(i).getSystemNo()));
			Cell systemOrgCell = row.createCell(2);
			systemOrgCell.setCellStyle(cellStyle1);
			systemOrgCell.setCellValue(listSmpService.get(i).getSystemOrg());
			// 交易码
			Cell transCodeCell = row.createCell(3);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(listSmpService.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					listSmpService.get(i).getTransCode() + "_" + listSmpService.get(i).getSystemNo() + "!A1");
			hyperlink.setLabel(listSmpService.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);
			// 交易名称
			Cell transName = row.createCell(4);
			transName.setCellStyle(cellStyle1);
			transName.setCellValue(listSmpService.get(i).getTransName());
			// 报文协议
			Cell msgAgreement = row.createCell(5);
			msgAgreement.setCellStyle(cellStyle1);
			msgAgreement.setCellValue(listSmpService.get(i).getMsgAgreement());
			// 报文编码
			Cell msgCodeCell = row.createCell(6);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", listSmpService.get(i).getMsgCode()));
			// esb地址
			Cell esbAddrCell = row.createCell(7);
			esbAddrCell.setCellStyle(cellStyle1);
			esbAddrCell.setCellValue(listSmpService.get(i).getEsbAddr());

			// 测试地址
			Cell testAddrCell = row.createCell(8);
			testAddrCell.setCellStyle(cellStyle1);
			testAddrCell.setCellValue(listSmpService.get(i).getTestAddr());

			// 生产地址
			/*
			 * Cell prodAddrCell = row.createCell(9); prodAddrCell.setCellStyle(cellStyle1);
			 * prodAddrCell.setCellValue(listSmpService.get(i).getProdAddr());
			 */

			// 外部可见
			Cell outShowCell = row.createCell(9);
			outShowCell.setCellStyle(cellStyle1);
			outShowCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", listSmpService.get(i).getOutShow()));
			//http请求方法
			Cell httpMethed = row.createCell(10);
			httpMethed.setCellStyle(cellStyle1);
			httpMethed.setCellValue( listSmpService.get(i).getHttpMethed());
			
			// 外部可见
			Cell operationShowCell = row.createCell(11);
			operationShowCell.setCellStyle(cellStyle1);
			operationShowCell.setCellValue("修改");

			Cell newTransCodeCell = row.createCell(12);
			newTransCodeCell.setCellStyle(cellStyle1);
			newTransCodeCell.setCellValue("");

			// 字段明细
			XSSFSheet sheetTransCode = workbook
					.createSheet(listSmpService.get(i).getTransCode() + "_" + listSmpService.get(i).getSystemNo());
			CellRangeAddress regin = new CellRangeAddress(1, 1, 1, 9);

			CellRangeAddress regin1 = new CellRangeAddress(2, 2, 1, 9);
			CellRangeAddress regin2 = new CellRangeAddress(3, 3, 1, 9);

			CellRangeAddress regin3 = new CellRangeAddress(4, 4, 1, 9);

//			CellRangeAddress regin4 = new CellRangeAddress(5, 5, 0, 9);

			sheetTransCode.addMergedRegion(regin);
			sheetTransCode.addMergedRegion(regin1);
			sheetTransCode.addMergedRegion(regin2);
			sheetTransCode.addMergedRegion(regin3);
//			sheetTransCode.addMergedRegion(regin4);

			row = sheetTransCode.createRow(0);

			Cell celltitle = row.createCell(0);
			celltitle.setCellValue("返回索引");
			XSSFHyperlink hyperlink1 = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			// Hyperlink linetoindex = sheetTransCode.addHyperlink(hyperlink);
			hyperlink1.setAddress("目录!D" + (i + 3));
			hyperlink1.setLabel("返回索引");
			celltitle.setHyperlink(hyperlink1);

			// celltitle.setCellStyle(cellStyle);
			row = sheetTransCode.createRow(1);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易码");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getTransCode());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}
			row = sheetTransCode.createRow(2);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易名称");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getTransName());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(3);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("功能简介");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getFunIntr());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(4);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("修改说明");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("");
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(5);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("请求字段");

			row = sheetTransCode.createRow(6);
			String[] fieldsTitle = { "序号", "字段代码", "字段名称", "父节点", "节点类型", "字段类型", "长度", "是否必输", "报文结构", "描述" };
			XSSFCellStyle cellStyle2 = workbook.createCellStyle();

			cellStyle2.setFillForegroundColor(xssfColor);
			cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
			cellStyle2.setAlignment(HorizontalAlignment.CENTER);

			cellStyle2.setBorderBottom(BorderStyle.THIN);
			cellStyle2.setBorderTop(BorderStyle.THIN);
			cellStyle2.setBorderLeft(BorderStyle.THIN);
			cellStyle2.setBorderRight(BorderStyle.THIN);

			for (int j = 0; j < fieldsTitle.length; j++) {
				 cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			// 输入
			SmpField smpField = new SmpField();
			smpField.setTransCode(listSmpService.get(i).getTransCode());
			smpField.setSystemNo(listSmpService.get(i).getSystemNo());
			smpField.setInOut("01");
			List<SmpField> smpFieldList = smpFieldMapper.getFieldByServer(smpField);
			int insize = smpFieldList.size();
			for (int j = 0; j < smpFieldList.size(); j++) {
				SmpField field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + 7);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);
				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

			// 输出
			row = sheetTransCode.createRow(insize + 7);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("响应字段");

			CellRangeAddress regin5 = new CellRangeAddress(insize + 7, insize + 7, 0, 9);

			sheetTransCode.addMergedRegion(regin5);

			row = sheetTransCode.createRow(insize + 8);
			for (int j = 0; j < fieldsTitle.length; j++) {
				cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			smpField.setTransCode(listSmpService.get(i).getTransCode());
			smpField.setSystemNo(listSmpService.get(i).getSystemNo());
			smpField.setInOut("02");
			smpFieldList = smpFieldMapper.getFieldByServer(smpField);
			for (int j = 0; j < smpFieldList.size(); j++) {
				SmpField field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + insize + 9);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);

				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

	/*
	 * 导出服务信息
	 * 
	 * @param pageRequest
	 * 
	 * @return
	 */
	public void buildSystem(OutputStream out, List<SmpServiceExtend> listSmpService, SmpSystem smpSystem) {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);
		Sheet sheetSystem = workbook.createSheet("系统详情");
		Row row = sheetSystem.createRow(1);
		Cell cell = row.createCell(0);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("系统名称");
		cell = row.createCell(1);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(smpSystem.getSystemName());
		cell = row.createCell(2);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("系统编号");
		cell = row.createCell(3);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(smpSystem.getSystemNo());
		row = sheetSystem.createRow(2);
		cell = row.createCell(0);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("系统机构号");
		cell = row.createCell(1);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(smpSystem.getSystemOrg());
		cell = row.createCell(2);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("系统简称");
		cell = row.createCell(3);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(smpSystem.getSystemShort());

		row = sheetSystem.createRow(3);
		cell = row.createCell(0);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("报文编码");
		cell = row.createCell(1);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(dataDictionaryCache.getItemName("SMP0004", smpSystem.getMsgCode()));
		cell = row.createCell(2);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("报文格式");
		cell = row.createCell(3);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(smpSystem.getMsgAgreement());
		row = sheetSystem.createRow(4);
		cell = row.createCell(0);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("系统类型");
		cell = row.createCell(1);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(dataDictionaryCache.getItemName("SMP0014", smpSystem.getSystemType()));

		cell = row.createCell(2);
		cell.setCellStyle(cellStyle1_1);
		cell.setCellValue("系统状态");
		cell = row.createCell(3);
		cell.setCellStyle(cellStyle1_2);
		cell.setCellValue(dataDictionaryCache.getItemName("SMP0002", smpSystem.getSystemStatus()));

		// 获取工作表名称是Index
		Sheet sheet = workbook.createSheet("目录");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 10 * 256);
		sheet.setColumnWidth(3, 10 * 256);
		sheet.setColumnWidth(4, 40 * 256);
		sheet.setColumnWidth(1, 20 * 256);
		sheet.setColumnWidth(7, 20 * 256);
		sheet.setColumnWidth(8, 40 * 256);
		sheet.setColumnWidth(9, 40 * 256);

		row = sheet.createRow(0);

		String[] title = new String[] { "系统编号", "系统名称", "机构号", "交易码", "交易名称", "报文协议", "报文编码", "ESB测试地址", "测试URL",
				"生产URL", "外部可见" };

		for (int i = 0; i < title.length; i++) {
			cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < listSmpService.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell systemNoCell = row.createCell(0);
			systemNoCell.setCellStyle(cellStyle1);
			systemNoCell.setCellValue(listSmpService.get(i).getSystemNo());
			// String systemName =
			// smpSystemMapper.getSystemInfo(listSmpService.get(i).getSystemNo()).getSystemName();
			Cell systemNameCell = row.createCell(1);
			systemNameCell.setCellStyle(cellStyle1);
			systemNameCell.setCellValue(SmpSystemCache.getSystemName(listSmpService.get(i).getSystemNo()));
			Cell systemOrgCell = row.createCell(2);
			systemOrgCell.setCellStyle(cellStyle1);
			systemOrgCell.setCellValue(listSmpService.get(i).getSystemOrg());
			// 交易码
			Cell transCodeCell = row.createCell(3);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(listSmpService.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					listSmpService.get(i).getTransCode() + "_" + listSmpService.get(i).getSystemNo() + "!A1");
			hyperlink.setLabel(listSmpService.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);
			// 交易名称
			Cell transName = row.createCell(4);
			transName.setCellStyle(cellStyle1);
			transName.setCellValue(listSmpService.get(i).getTransName());
			// 报文协议
			Cell msgAgreement = row.createCell(5);
			msgAgreement.setCellStyle(cellStyle1);
			msgAgreement.setCellValue(listSmpService.get(i).getMsgAgreement());
			// 报文编码
			Cell msgCodeCell = row.createCell(6);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", listSmpService.get(i).getMsgCode()));
			// esb地址
			Cell esbAddrCell = row.createCell(7);
			esbAddrCell.setCellStyle(cellStyle1);
			esbAddrCell.setCellValue(listSmpService.get(i).getEsbAddr());

			// 测试地址
			Cell testAddrCell = row.createCell(8);
			testAddrCell.setCellStyle(cellStyle1);
			testAddrCell.setCellValue(listSmpService.get(i).getTestAddr());

			// 生产地址
			Cell prodAddrCell = row.createCell(9);
			prodAddrCell.setCellStyle(cellStyle1);
			prodAddrCell.setCellValue(listSmpService.get(i).getProdAddr());

			// 外部可见
			Cell outShowCell = row.createCell(10);
			outShowCell.setCellStyle(cellStyle1);
			outShowCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", listSmpService.get(i).getOutShow()));

			// 字段明细
			XSSFSheet sheetTransCode = workbook
					.createSheet(listSmpService.get(i).getTransCode() + "_" + listSmpService.get(i).getSystemNo());
			CellRangeAddress regin = new CellRangeAddress(1, 1, 1, 9);

			CellRangeAddress regin1 = new CellRangeAddress(2, 2, 1, 9);
			CellRangeAddress regin2 = new CellRangeAddress(3, 3, 1, 9);

			CellRangeAddress regin3 = new CellRangeAddress(4, 4, 0, 9);

			sheetTransCode.addMergedRegion(regin);
			sheetTransCode.addMergedRegion(regin1);
			sheetTransCode.addMergedRegion(regin2);
			sheetTransCode.addMergedRegion(regin3);

			row = sheetTransCode.createRow(0);

			Cell celltitle = row.createCell(0);
			celltitle.setCellValue("返回索引");
			XSSFHyperlink hyperlink1 = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			// Hyperlink linetoindex = sheetTransCode.addHyperlink(hyperlink);
			hyperlink1.setAddress("目录!D" + (i + 3));
			hyperlink1.setLabel("返回索引");
			celltitle.setHyperlink(hyperlink1);

			// celltitle.setCellStyle(cellStyle);
			row = sheetTransCode.createRow(1);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易码");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getTransCode());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}
			row = sheetTransCode.createRow(2);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易名称");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getTransName());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}
			row = sheetTransCode.createRow(3);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("功能简介");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getFunIntr());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(4);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("请求字段");

			row = sheetTransCode.createRow(5);
			String[] fieldsTitle = { "序号", "字段代码", "字段名称", "父节点", "节点类型", "字段类型", "长度", "是否必输", "报文结构", "描述" };
			XSSFCellStyle cellStyle2 = workbook.createCellStyle();

			cellStyle2.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
			cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
			cellStyle2.setAlignment(HorizontalAlignment.CENTER);

			cellStyle2.setBorderBottom(BorderStyle.THIN);
			cellStyle2.setBorderTop(BorderStyle.THIN);
			cellStyle2.setBorderLeft(BorderStyle.THIN);
			cellStyle2.setBorderRight(BorderStyle.THIN);

			for (int j = 0; j < fieldsTitle.length; j++) {
				cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			// 输入
			SmpField smpField = new SmpField();
			smpField.setTransCode(listSmpService.get(i).getTransCode());
			smpField.setSystemNo(listSmpService.get(i).getSystemNo());
			smpField.setInOut("01");
			List<SmpField> smpFieldList = smpFieldMapper.getFieldByServer(smpField);
			int insize = smpFieldList.size();
			for (int j = 0; j < smpFieldList.size(); j++) {
				SmpField field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + 6);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);
				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

			// 输出
			row = sheetTransCode.createRow(insize + 6);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("响应字段");

			CellRangeAddress regin4 = new CellRangeAddress(insize + 6, insize + 6, 0, 9);

			sheetTransCode.addMergedRegion(regin4);

			row = sheetTransCode.createRow(insize + 7);
			for (int j = 0; j < fieldsTitle.length; j++) {
				cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			smpField.setTransCode(listSmpService.get(i).getTransCode());
			smpField.setSystemNo(listSmpService.get(i).getSystemNo());
			smpField.setInOut("02");
			smpFieldList = smpFieldMapper.getFieldByServer(smpField);
			for (int j = 0; j < smpFieldList.size(); j++) {
				SmpField field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + insize + 8);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);

				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

	// 查询服务信息
	@RequestMapping("/getServiceInfo")
	public ResponseMessage<SmpService> getServiceInfo(@RequestParam String busCode, @RequestParam String systemNo) {
		ResponseMessage<SmpService> responseMessage = new ResponseMessage<SmpService>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询服务信息成功！");

		SmpService SmpService = new SmpService();
		SmpService.setBusCode(busCode);
		SmpService.setSystemNo(systemNo);
		SmpService smpService = smpServiceMapper.getServiceInfo(SmpService);
		if (smpService == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询服务信息失败！");
		}
		responseMessage.setExtend(smpService);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 查询服务信息-历史服务
	 * 
	 * @param pageRequest
	 * @return
	 */
	@RequestMapping("/getHisByServer")
	public ResponseMessage<PageInfo<SmpServiceHis>> getHisByServer(
			@RequestBody PageRequest<SmpServiceExtend> pageRequest) {
		ResponseMessage<PageInfo<SmpServiceHis>> responseMessage = new ResponseMessage<PageInfo<SmpServiceHis>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询服务信息成功！");

		SmpServiceHis smpServiceHis = new SmpServiceHis();
		smpServiceHis.setBusCode(pageRequest.getBody().getBusCode());
		smpServiceHis.setSystemNo(pageRequest.getBody().getSystemNo());
		List<SmpServiceHis> smpServiceHisList = smpServiceHisMapper.getHisByServer(smpServiceHis);
		if (smpServiceHisList == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询服务信息失败！");
		}

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		PageInfo<SmpServiceHis> pageInfo = new PageInfo<SmpServiceHis>(smpServiceHisList, pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 查询消费信息和调用列表
	@RequestMapping("/getConsumeInfo")
	public ResponseMessage<SmpServiceDetails> getConsumeInfo(@RequestBody PageRequest<SmpServiceExtend> pageRequest) {
		ResponseMessage<SmpServiceDetails> responseMessage = new ResponseMessage<SmpServiceDetails>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询消费信息和调用列表信息成功！");

		SmpService smpService = new SmpService();
		smpService.setSystemNo(pageRequest.getBody().getSystemNo());
		smpService.setBusCode(pageRequest.getBody().getBusCode());

		SmpConsume smpConsume = new SmpConsume();
		smpConsume.setBusCode(pageRequest.getBody().getBusCode());
		smpConsume.setSystemNo(pageRequest.getBody().getSystemNo());

		List<SmpConsume> listSmpConsume = smpConsumeMapper.getConsumeInfo(smpConsume);
		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		List<CallListInfo> listCallListInfo = smpSystemCallMapper.getCallListInfo(smpService);
		if (listCallListInfo == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询调用列表信息失败！");
		}
		PageInfo<CallListInfo> pageInfo = new PageInfo<CallListInfo>(listCallListInfo, pageRequest.getPageSize());

		SmpServiceDetails smpServiceDetails = new SmpServiceDetails();
		smpServiceDetails.setSmpConsumeLists(listSmpConsume);
		smpServiceDetails.setPageInfo(pageInfo);
		responseMessage.setExtend(smpServiceDetails);
		return responseMessage;
	}

	// 查询消费信息和调用列表
	@RequestMapping("/selectSystemCallByPage")
	public ResponseMessage<PageInfo<SmpSystemCallExtend>> selectSystemCallByPage(
			@RequestBody PageRequest<SmpSystemCallExtend> pageRequest) {
		ResponseMessage<PageInfo<SmpSystemCallExtend>> responseMessage = new ResponseMessage<PageInfo<SmpSystemCallExtend>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询消费信息和调用列表信息成功！");

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());

		List<SmpSystemCallExtend> listCallListInfo = smpSystemCallMapper.selectSystemCallByPage(pageRequest.getBody());

		if (listCallListInfo == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询调用列表信息失败！");
		}
		PageInfo<SmpSystemCallExtend> pageInfo = new PageInfo<SmpSystemCallExtend>(listCallListInfo,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		return responseMessage;
	}

	// 分页查询系统信息
	@RequestMapping("/getSystemInfoByPage")
	public ResponseMessage<PageInfo<SmpSystem>> getSystemInfoByPage(@RequestBody PageRequest<SmpSystem> pageRequest) {
		ResponseMessage<PageInfo<SmpSystem>> responseMessage = new ResponseMessage<PageInfo<SmpSystem>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("分页查询系统信息成功！");

		SmpSystem smpServiceManagementSystem = pageRequest.getBody();

		String systemResponsibleMan = request.getHeader("userName");

		smpServiceManagementSystem.setSystemResponsibleMan(systemResponsibleMan);

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());

		List<SmpSystem> listSmpServiceManagementSystem = smpSystemMapper
				.getSystemInfoByPage(smpServiceManagementSystem);
		if (listSmpServiceManagementSystem == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询服务信息失败！");
		}
		PageInfo<SmpSystem> pageInfo = new PageInfo<SmpSystem>(listSmpServiceManagementSystem,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 分页查询系统信息
	@RequestMapping("/getSystemInfoByPageNew")
	public ResponseMessage<PageInfo<SmpSystem>> getSystemInfoByPageNew(
			@RequestBody PageRequest<SmpSystem> pageRequest) {
		ResponseMessage<PageInfo<SmpSystem>> responseMessage = new ResponseMessage<PageInfo<SmpSystem>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("分页查询系统信息成功！");

		SmpSystem smpServiceManagementSystem = pageRequest.getBody();

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());

		List<SmpSystem> listSmpServiceManagementSystem = smpSystemMapper
				.getSystemInfoByPage(smpServiceManagementSystem);
		if (listSmpServiceManagementSystem == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询服务信息失败！");
		}
		PageInfo<SmpSystem> pageInfo = new PageInfo<SmpSystem>(listSmpServiceManagementSystem,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 分页查询系统信息
	@RequestMapping("/selectSystemInfoAll")
	public ResponseMessage<List<SmpSystem>> selectSystemInfoAll() {
		ResponseMessage<List<SmpSystem>> responseMessage = new ResponseMessage<List<SmpSystem>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("分页查询系统信息成功！");

		List<SmpSystem> listSmpServiceManagementSystem = SmpSystemCache.getSmpSystemList();
		if (listSmpServiceManagementSystem == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询系统信息失败！");
		}
		responseMessage.setExtend(listSmpServiceManagementSystem);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 查询当前用户负责系统
	 * 
	 * @return
	 */
	@RequestMapping("/selectSystemInfoByResponsibleMan")
	public ResponseMessage<List<SmpSystem>> selectSystemInfoByResponsibleMan() {
		ResponseMessage<List<SmpSystem>> responseMessage = new ResponseMessage<List<SmpSystem>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询系统信息成功！");
		String userName = request.getHeader("userName");
		SmpSystem smpSystem = new SmpSystem();

		smpSystem.setSystemResponsibleMan(userName);

		List<SmpSystem> listSmpServiceManagementSystem = smpSystemMapper.getSystemInfoByPage(smpSystem);
		if (listSmpServiceManagementSystem == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询系统信息失败！");
		}
		responseMessage.setExtend(listSmpServiceManagementSystem);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 查询系统信息
	@RequestMapping("/getSystemInfo")
	public ResponseMessage<SmpSystem> getSystemInfo(@RequestParam String systemNo) {

		ResponseMessage<SmpSystem> responseMessage = new ResponseMessage<SmpSystem>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询系统信息成功！");

		SmpSystem smpServiceManagementSystem = smpSystemMapper.getSystemInfo(systemNo);
		if (smpServiceManagementSystem == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询系统信息失败！");
		}
		responseMessage.setExtend(smpServiceManagementSystem);
		logger.info(responseMessage.getMessage());
		return responseMessage;

	}

	// 添加服务调用
	@RequestMapping("/addServiceInfo")
	public ResponseMessage addServiceInfo(@RequestBody SmpSystemCall smpSystemCall) {
		ResponseMessage responseMessage = new ResponseMessage();
		responseMessage.setCode("0000");
		responseMessage.setMessage("添加服务调用成功！");
		smpSystemCall.setStatus("01");
		smpSystemCall.setCreateTime(new Date());
		smpSystemCallMapper.insertSelective(smpSystemCall);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 登记系统信息
	@RequestMapping("/addSystemInfo")
	public ResponseMessage addSystemInfo(@RequestBody SmpSystem smpServiceManagementSystem) {
		ResponseMessage responseMessage = new ResponseMessage();
		responseMessage.setCode("0000");
		responseMessage.setMessage("系统登记成功！");
		smpSystemMapper.insertSelective(smpServiceManagementSystem);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 修改系统信息
	@RequestMapping("/updateSystemInfo")
	public void updateSystemInfo(@RequestBody SmpSystem smpServiceManagementSystem) {

		smpSystemMapper.updateByPrimaryKeySelective(smpServiceManagementSystem);
		systemCache.init();

	}

	// 分页查询消费接口列表
	@RequestMapping("/getSysInterfaceListByPage")
	public ResponseMessage<PageInfo<SmpInterfaceList>> getSysInterfaceListByPage(
			@RequestBody PageRequest<SmpSystem> pageRequest) {
		ResponseMessage<PageInfo<SmpInterfaceList>> responseMessage = new ResponseMessage<PageInfo<SmpInterfaceList>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询消费接口列表信息成功！");

		String systemNo = pageRequest.getBody().getSystemNo();
		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());

		List<SmpInterfaceList> listSmpSysInterface = smpSystemCallMapper.getSysInterfaceListByPage(systemNo);
		if (listSmpSysInterface == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询消费接口列表信息失败！");
		}
		PageInfo<SmpInterfaceList> pageInfo = new PageInfo<SmpInterfaceList>(listSmpSysInterface,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 分页查询服务接口列表
	@RequestMapping("/getBusInterfaceListByPage")
	public ResponseMessage<PageInfo<SmpInterfaceList>> getBusInterfaceListByPage(
			@RequestBody PageRequest<SmpSystem> pageRequest) {
		ResponseMessage<PageInfo<SmpInterfaceList>> responseMessage = new ResponseMessage<PageInfo<SmpInterfaceList>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询服务接口列表信息成功！");

		String systemNo = pageRequest.getBody().getSystemNo();
		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());

		List<SmpInterfaceList> listSmpBusInterface = smpSystemCallMapper.getBusInterfaceListByPage(systemNo);
		if (listSmpBusInterface == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询服务接口列表信息失败！");
		}
		PageInfo<SmpInterfaceList> pageInfo = new PageInfo<SmpInterfaceList>(listSmpBusInterface,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 分页关联系统接口列表
	@RequestMapping("/getInteractedSystemListByPage")
	public ResponseMessage<PageInfo<IntercatedSystemList>> getInteractedSystemListByPage(
			@RequestBody PageRequest<SmpSystem> pageRequest) {
		ResponseMessage<PageInfo<IntercatedSystemList>> responseMessage = new ResponseMessage<PageInfo<IntercatedSystemList>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询关联系统列表信息成功！");

		String systemNo = pageRequest.getBody().getSystemNo();
		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());

		List<IntercatedSystemList> listIntercatedSystem = smpSystemCallMapper.getInteractedSystemListByPage(systemNo);
		if (listIntercatedSystem == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询关联系统列表信息失败！");
		}
		PageInfo<IntercatedSystemList> pageInfo = new PageInfo<IntercatedSystemList>(listIntercatedSystem,
				pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	// 查询消费(服务)系统数
	@RequestMapping("/getSystemNums")
	public ResponseMessage<SystemNums> getSystemNums(@RequestParam String systemNo) {

		ResponseMessage<SystemNums> responseMessage = new ResponseMessage<SystemNums>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询消费(服务)系统数成功！");
		SystemNums sysNums = new SystemNums();
		sysNums.setPubSystemNum(smpSystemCallMapper.getPubSystemNum(systemNo));
		sysNums.setRegSystemNum(smpSystemCallMapper.getRegSystemNum(systemNo));
		responseMessage.setExtend(sysNums);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 首页查询系统数
	 * 
	 * @return
	 */
	@RequestMapping("/selectSystemNum")
	public ResponseMessage<Map> selectSystemNum() {

		ResponseMessage<Map> responseMessage = new ResponseMessage<Map>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询消费(服务)系统数成功！");

		Map m = new HashMap<>();

		int a = smpSystemMapper.selectAllByCount();
		int b = smpSystemMapper.selectInByCount();
		int c = smpSystemMapper.selectOutByCount();
		m.put("zongNum", a);
		m.put("inNum", b);
		m.put("outNum", c);

		responseMessage.setExtend(m);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 修改业务路由信息
	 * 
	 * @param smpConsume
	 */
	@RequestMapping("/serviceUpdate")
	public void serviceUpdate(@RequestBody SmpConsume smpConsume) {
		smpConsumeMapper.updateByPrimaryKeySelective(smpConsume);
	}

	/**
	 * 首页查询投产服务数
	 * 
	 * @return
	 */
	@RequestMapping("/selectServiceNum")
	public ResponseMessage<Map> selectServiceNum() {

		ResponseMessage<Map> responseMessage = new ResponseMessage<Map>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询消费(服务)数成功！");

		Map m = new HashMap<>();

		int a = smpServiceMapper.selectAllByCount();
		int b = smpServiceMapper.selectInByCount();
		int c = smpServiceMapper.selectOutByCount();
		m.put("zongNum", a);
		m.put("inNum", b);
		m.put("otherNum", c);

		responseMessage.setExtend(m);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 首页查询TOP10服务数的内联系统
	 * 
	 * @return
	 */
	@RequestMapping("/selectEsbTop")
	public ResponseMessage<List<VueData>> selectEsbTop() {

		ResponseMessage<List<VueData>> responseMessage = new ResponseMessage<List<VueData>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		List<VueData> vueDataList = smpSystemMapper.selectEsbTop();
		if (vueDataList == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询失败！");
		}

		responseMessage.setExtend(vueDataList);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 首页查询TOP10服务数的外联系统
	 * 
	 * @return
	 */
	@RequestMapping("/selectOesbTop")
	public ResponseMessage<List<VueData>> selectOesbTop() {

		ResponseMessage<List<VueData>> responseMessage = new ResponseMessage<List<VueData>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		List<VueData> vueDataList = smpSystemMapper.selectOesbTop();
		if (vueDataList == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询失败！");
		}

		responseMessage.setExtend(vueDataList);
		logger.info(responseMessage.getMessage());
		return responseMessage;
	}

	/**
	 * 服务删除
	 * 
	 * @param smpService
	 * @return
	 */
	@Transactional
	@RequestMapping("/deteleService")
	public ResponseMessage deteleService(@RequestBody SmpService smpService) {
		ResponseMessage responseMessage = new ResponseMessage();
		responseMessage.setCode("0000");
		responseMessage.setMessage("删除服务信息成功！");

		// 查询是否有调用列表信息 SMP_SYSTEM_CALL 有就不能删除，没有就删除 SMP_SERVICE，SMP_CONSUME，SMP_FIELD
		// 三张表
		int a = smpSystemCallMapper.getByCount(smpService);

		if (a == 0) { // 无调用列表信息 SMP_SYSTEM_CALL

			// 删除SMP_SERVICE
			SmpServiceKey smpServiceKey = new SmpServiceKey();
			smpServiceKey.setTransCode(smpService.getTransCode());
			smpServiceKey.setSystemNo(smpService.getSystemNo());
			smpServiceMapper.deleteByPrimaryKey(smpServiceKey);

			// 删除SMP_CONSUME
			SmpConsumeKey smpConsumeKey = new SmpConsumeKey();
			smpConsumeKey.setBusCode(smpService.getBusCode());
			smpConsumeKey.setSystemNo(smpService.getSystemNo());
			smpConsumeMapper.deleteByKey(smpConsumeKey);

			// 删除SMP_FIELD
			SmpField smpField = new SmpField();
			smpField.setTransCode(smpService.getTransCode());
			smpField.setSystemNo(smpService.getSystemNo());
			smpFieldMapper.deleteByTransCodeAndSystemNo(smpField);

		} else {
			responseMessage.setCode("0001");
			responseMessage.setMessage("存在服务调用不可删除！");
		}
		return responseMessage;
	}

	/**
	 * 系统删除
	 * 
	 * @param smpSystem
	 * @return
	 */
	@Transactional
	@RequestMapping("/deteleSystem")
	public ResponseMessage deteleSystem(@RequestBody SmpSystem smpSystem) {
		ResponseMessage responseMessage = new ResponseMessage();
		responseMessage.setCode("0000");
		responseMessage.setMessage("删除系统信息成功！");

		// 查询是否有调用信息 SMP_SYSTEM_CALL，SMP_SERVICE 有就不能删除，没有就删除 SMP_SYSTEM

		int a = smpSystemCallMapper.getRegSystemNum(smpSystem.getSystemNo());
		int b = smpServiceMapper.getCountBySystemNo(smpSystem.getSystemNo());

		if (a == 0 && b == 0) { // 无调用列表信息 SMP_SYSTEM_CALL，SMP_SERVICE

			// 删除SMP_SYSTEM
			smpSystemMapper.deleteByPrimaryKey(smpSystem.getSystemNo());

		} else {
			responseMessage.setCode("0001");
			responseMessage.setMessage("存在服务调用不可删除！");
		}
		return responseMessage;
	}

	@RequestMapping("getConsumeInfoByQmsNo")
	public ResponseMessage<PageInfo<CallListInfo>> getConsumeInfoByQmsNo(
			@RequestBody PageRequest<SmpSystemCall> pageRequest) {

		ResponseMessage<PageInfo<CallListInfo>> responseMessage = new ResponseMessage<PageInfo<CallListInfo>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询调用信息成功！");

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		List<CallListInfo> listConsumeInfo = smpSystemCallMapper.getConsumeInfoByQmsNo(pageRequest.getBody());

		if (listConsumeInfo == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询调用信息失败！");
		}
		PageInfo<CallListInfo> pageInfo = new PageInfo<CallListInfo>(listConsumeInfo, pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		return responseMessage;
	}

	/**
	 * 解除调用
	 * 
	 * @param pageRequest
	 * @return
	 */
	@RequestMapping("getServiceViewDel")
	public ResponseMessage<PageInfo<CallListInfo>> getServiceViewDel(
			@RequestBody PageRequest<SmpSystemCallExtend> pageRequest) {

		ResponseMessage<PageInfo<CallListInfo>> responseMessage = new ResponseMessage<PageInfo<CallListInfo>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询调用信息成功！");

		PageHelper.startPage(pageRequest.getPageNum(), pageRequest.getPageSize());
		List<CallListInfo> listConsumeInfo = smpSystemCallMapper.getServiceViewDel(pageRequest.getBody());

		if (listConsumeInfo == null) {
			responseMessage.setCode("0001");
			responseMessage.setMessage("查询调用信息失败！");
		}
		PageInfo<CallListInfo> pageInfo = new PageInfo<CallListInfo>(listConsumeInfo, pageRequest.getPageSize());
		responseMessage.setExtend(pageInfo);
		return responseMessage;
	}

	/**
	 * 导出服务调用信息
	 * 
	 * @param pageRequest
	 * @return
	 */
	@RequestMapping("exportCallList")
	public void exportCallList(@RequestBody PageRequest<SmpSystemCall> pageRequest) {
		List<CallListInfo> callListInfoList = smpSystemCallMapper.getConsumeInfoByQmsNo(pageRequest.getBody());

		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);

		// 获取工作表名称是Index
		// Sheet sheet =
		// workbook.createSheet(pageRequest.getBody().getAssociatedRequirement()+"_服务调用");
		Sheet sheet = workbook.createSheet("目录");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 15 * 256);
		sheet.setColumnWidth(1, 30 * 256);
		sheet.setColumnWidth(2, 15 * 256);
		sheet.setColumnWidth(3, 15 * 256);
		sheet.setColumnWidth(4, 20 * 256);
		sheet.setColumnWidth(5, 15 * 256);
		sheet.setColumnWidth(6, 20 * 256);
		sheet.setColumnWidth(7, 15 * 256);
		sheet.setColumnWidth(8, 15 * 256);
		sheet.setColumnWidth(9, 15 * 256);
		sheet.setColumnWidth(10, 50 * 256);

		Row row = sheet.createRow(0);

		String[] title = new String[] { "交易码", "交易名称", "服务编码(R)", "服务系统编码", "服务系统名称", "消费系统编码", "消费系统名称", "消费方报文格式",
				"消费方字符编码", "服务编码(P)", "访问URL" };

		for (int i = 0; i < title.length; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < callListInfoList.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell transCodeCell = row.createCell(0);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(callListInfoList.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					callListInfoList.get(i).getTransCode() + "_" + callListInfoList.get(i).getRegSysCode() + "!A1");
			hyperlink.setLabel(callListInfoList.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);

			// String systemName =
			// smpSystemMapper.getSystemInfo(listSmpService.get(i).getSystemNo()).getSystemName();
			Cell transNameCell = row.createCell(1);
			transNameCell.setCellStyle(cellStyle1);
			transNameCell.setCellValue(callListInfoList.get(i).getTransName());

			Cell busCodeCell = row.createCell(2);
			busCodeCell.setCellStyle(cellStyle1);
			busCodeCell.setCellValue(callListInfoList.get(i).getBusCode());

			Cell regSysCodeCell = row.createCell(3);
			regSysCodeCell.setCellStyle(cellStyle1);
			regSysCodeCell.setCellValue(callListInfoList.get(i).getRegSysCode());

			String regsystemName = smpSystemMapper.getSystemInfo(callListInfoList.get(i).getRegSysCode())
					.getSystemName();

			Cell regsystemNameCell = row.createCell(4);
			regsystemNameCell.setCellStyle(cellStyle1);
			regsystemNameCell.setCellValue(regsystemName);

			Cell pubSysCodeCell = row.createCell(5);
			pubSysCodeCell.setCellStyle(cellStyle1);
			pubSysCodeCell.setCellValue(callListInfoList.get(i).getSystemNo());

			String pubsystemName = smpSystemMapper.getSystemInfo(callListInfoList.get(i).getSystemNo()).getSystemName();
			Cell pubsystemNameCell = row.createCell(6);
			pubsystemNameCell.setCellStyle(cellStyle1);
			pubsystemNameCell.setCellValue(pubsystemName);

			Cell msgAgreementCell = row.createCell(7);
			msgAgreementCell.setCellStyle(cellStyle1);
			msgAgreementCell.setCellValue(callListInfoList.get(i).getMsgAgreement());

			Cell msgCodeCell = row.createCell(8);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", callListInfoList.get(i).getMsgCode()));

			Cell pubCodeCell = row.createCell(9);
			pubCodeCell.setCellStyle(cellStyle1);
			pubCodeCell.setCellValue(callListInfoList.get(i).getPubCode());

			Cell proxyPathCell = row.createCell(10);
			proxyPathCell.setCellStyle(cellStyle1);
			proxyPathCell.setCellValue(callListInfoList.get(i).getProxyPath());
		}

		List<String> servers = new ArrayList<String>();
		List<SmpService> smpServiceList = new ArrayList<>();
		for (CallListInfo callInfo : callListInfoList) {
			if (!servers.contains(callInfo.getTransCode() + "_" + callInfo.getRegSysCode())) {
				servers.add(callInfo.getTransCode() + "_" + callInfo.getRegSysCode());// 去重处理
				SmpService smpService = new SmpService();
				smpService.setSystemNo(callInfo.getRegSysCode());
				smpService.setTransCode(callInfo.getTransCode());
				smpService.setTransName(callInfo.getTransName());
				smpServiceList.add(smpService);
			}
		}

		buildServiceByCall(workbook, smpServiceList);

		OutputStream out = null;
		try {
			out = response.getOutputStream();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 导出服务信息
	 * 
	 * @param pageRequest
	 * @return
	 */
	public void buildServiceByCall(XSSFWorkbook workbook, List<SmpService> listSmpService) {
		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);

		for (int i = 0; i < listSmpService.size(); i++) {
			// 字段明细
			XSSFSheet sheetTransCode = workbook
					.createSheet(listSmpService.get(i).getTransCode() + "_" + listSmpService.get(i).getSystemNo());
			CellRangeAddress regin = new CellRangeAddress(1, 1, 1, 9);

			CellRangeAddress regin1 = new CellRangeAddress(2, 2, 1, 9);
			CellRangeAddress regin2 = new CellRangeAddress(3, 3, 1, 9);

			CellRangeAddress regin3 = new CellRangeAddress(4, 4, 1, 9);

//			CellRangeAddress regin4 = new CellRangeAddress(5, 5, 0, 9);

			sheetTransCode.addMergedRegion(regin);
			sheetTransCode.addMergedRegion(regin1);
			sheetTransCode.addMergedRegion(regin2);
			sheetTransCode.addMergedRegion(regin3);
//			sheetTransCode.addMergedRegion(regin4);

			Row row = sheetTransCode.createRow(0);

			Cell celltitle = row.createCell(0);
			celltitle.setCellValue("返回索引");
			XSSFHyperlink hyperlink1 = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			// Hyperlink linetoindex = sheetTransCode.addHyperlink(hyperlink);
			hyperlink1.setAddress("目录!D" + (i + 3));
			hyperlink1.setLabel("返回索引");
			celltitle.setHyperlink(hyperlink1);

			// celltitle.setCellStyle(cellStyle);
			row = sheetTransCode.createRow(1);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易码");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getTransCode());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}
			row = sheetTransCode.createRow(2);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易名称");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getTransName());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(3);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("功能简介");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpService.get(i).getFunIntr());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(4);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("修改说明");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("");
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(5);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("请求字段");

			row = sheetTransCode.createRow(6);
			String[] fieldsTitle = { "序号", "字段代码", "字段名称", "父节点", "节点类型", "字段类型", "长度", "是否必输", "报文结构", "描述" };
			XSSFCellStyle cellStyle2 = workbook.createCellStyle();

			cellStyle2.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
			cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
			cellStyle2.setAlignment(HorizontalAlignment.CENTER);

			cellStyle2.setBorderBottom(BorderStyle.THIN);
			cellStyle2.setBorderTop(BorderStyle.THIN);
			cellStyle2.setBorderLeft(BorderStyle.THIN);
			cellStyle2.setBorderRight(BorderStyle.THIN);

			for (int j = 0; j < fieldsTitle.length; j++) {
				Cell cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			// 输入
			SmpField smpField = new SmpField();
			smpField.setTransCode(listSmpService.get(i).getTransCode());
			smpField.setSystemNo(listSmpService.get(i).getSystemNo());
			smpField.setInOut("01");
			List<SmpField> smpFieldList = smpFieldMapper.getFieldByServer(smpField);
			int insize = smpFieldList.size();
			for (int j = 0; j < smpFieldList.size(); j++) {
				SmpField field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + 7);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);
				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

			// 输出
			row = sheetTransCode.createRow(insize + 7);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("响应字段");

			CellRangeAddress regin5 = new CellRangeAddress(insize + 7, insize + 7, 0, 9);

			sheetTransCode.addMergedRegion(regin5);

			row = sheetTransCode.createRow(insize + 8);
			for (int j = 0; j < fieldsTitle.length; j++) {
				Cell cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			smpField.setTransCode(listSmpService.get(i).getTransCode());
			smpField.setSystemNo(listSmpService.get(i).getSystemNo());
			smpField.setInOut("02");
			smpFieldList = smpFieldMapper.getFieldByServer(smpField);
			for (int j = 0; j < smpFieldList.size(); j++) {
				SmpField field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + insize + 9);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);

				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

		}

		/*
		 * try { workbook.write(out); } catch (IOException e) { // TODO Auto-generated
		 * catch block e.printStackTrace(); } finally { try { workbook.close(); } catch
		 * (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
		 */

	}

	/**
	 * 测试结果上传
	 * 
	 * @param file
	 * @param fileName
	 * @param fileDescribe
	 * @param testResult
	 * @param pubCode
	 * @param regSysCode
	 * @param pubSysCode
	 * @return
	 */
	@RequestMapping("/addTestResult")
	public ResponseMessage<?> addTestResult(MultipartFile file, @RequestParam(name = "fileName") String fileName,
			@RequestParam(name = "fileDescribe") String fileDescribe,
			@RequestParam(name = "testResult") String testResult, @RequestParam(name = "pubCode") String pubCode,
			@RequestParam(name = "regSysCode") String regSysCode,
			@RequestParam(name = "pubSysCode") String pubSysCode) {

		ResponseMessage<?> response = new ResponseMessage<>();
		response.setCode("0000");
		response.setMessage("测试结果上传成功！");

		Date date = new Date();

		SmpSystemCall smpSystemCall = new SmpSystemCall();

		try {
			smpSystemCall.setPubCode(pubCode);
			smpSystemCall.setRegSysCode(regSysCode);
			smpSystemCall.setPubSysCode(pubSysCode);
			smpSystemCall.setTestResult(testResult);
			smpSystemCall.setTestImg(file.getBytes());

			smpSystemCallMapper.updateByPrimaryKeySelective(smpSystemCall);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return response;
	}

	/**
	 * 服务视图导入
	 * 
	 * @param file
	 * @return
	 */
	@RequestMapping("/getFileByExcel")
	public ResponseMessage<?> getFileByExcel(MultipartFile file) {

		ResponseMessage<?> response = new ResponseMessage<>();
		response.setCode("0000");
		response.setMessage("导入成功！");

//	        List<SmpServiceExtend>  smpServiceExtendList = new ArrayList<>();

		try {
			Workbook workbook = new XSSFWorkbook(file.getInputStream());
			// 获取工作表名称是Index
			Sheet sheet = workbook.getSheet("目录");

			for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {

				Row row = sheet.getRow(i);// 行从第二行开始
				String systemNo = "";
				try {
					systemNo = row.getCell(0).getStringCellValue();
				} catch (Exception e) {
					try {
						systemNo = Double.toString(row.getCell(0).getNumericCellValue());
					} catch (Exception e1) {
						// TODO: handle exception
					}
				}

				// 没有值得时候跳出循环
				if (row == null || row.getCell(0) == null || "".equals(systemNo)) {
					break;
				}
				SmpServiceExtend smpServiceExtend = new SmpServiceExtend();

				// 系统编码

				smpServiceExtend.setSystemNo(systemNo);

				// 机构号
				try {
					smpServiceExtend.setSystemOrg(row.getCell(2).getStringCellValue());
				} catch (Exception e) {
					try {
						smpServiceExtend.setSystemOrg(Double.toString(row.getCell(2).getNumericCellValue()));
					} catch (Exception e1) {
						// TODO: handle exception
					}
				}

				String transCode = null;

				try {
					transCode = row.getCell(3).getStringCellValue();
				} catch (Exception e) {
					try {
						transCode = Double.toString(row.getCell(3).getNumericCellValue());
					} catch (Exception e1) {

					}
				}

				smpServiceExtend.setTransCode(transCode);

				try {
					smpServiceExtend.setTransName(row.getCell(4).getStringCellValue());
				} catch (Exception e1) {
					// TODO: handle exception
				}

				try {
					smpServiceExtend.setMsgAgreement(row.getCell(5).getStringCellValue());
				} catch (Exception e1) {
					// TODO: handle exception
				}

				// 报文编码 01 utf-8 02 gbk
				/*
				 * if("utf-8".equals(row.getCell(6).getStringCellValue())) {
				 * applyServerExtend.setMsgCode("01"); }else if
				 * ("gbk".equals(row.getCell(6).getStringCellValue())) {
				 * applyServerExtend.setMsgCode("02"); }
				 */
				try {
					String msgCode = DataDictionaryCache.getItemCode("SMP0004", row.getCell(6).getStringCellValue());
					smpServiceExtend.setMsgCode(msgCode);
				} catch (Exception e1) {
					// TODO: handle exception
				}

				try {
					smpServiceExtend.setEsbAddr(row.getCell(7).getStringCellValue());
				} catch (Exception e1) {
					// TODO: handle exception
				}

				try {
					smpServiceExtend.setTestAddr(row.getCell(8).getStringCellValue());
				} catch (Exception e1) {
					// TODO: handle exception
				}

				// 外部可见 01 是 02 否
				/*
				 * if("是".equals(row.getCell(10).getStringCellValue())) {
				 * applyServerExtend.setOutShow("01"); }else if
				 * ("否".equals(row.getCell(10).getStringCellValue())) {
				 * applyServerExtend.setOutShow("02"); }
				 */

				try {
					String outShow = DataDictionaryCache.getItemCode("SMP0015", row.getCell(9).getStringCellValue());
					smpServiceExtend.setOutShow(outShow);
				} catch (Exception e1) {
					// TODO: handle exception
				}

				// 申请类型 01 新增 02 修改 03 删除
				/*
				 * if("新增".equals(row.getCell(11).getStringCellValue())) {
				 * applyServerExtend.setRequireType("01"); }else if
				 * ("修改".equals(row.getCell(11).getStringCellValue())) {
				 * applyServerExtend.setRequireType("02"); }else if
				 * ("删除".equals(row.getCell(11).getStringCellValue())) {
				 * applyServerExtend.setRequireType("03"); }
				 */

				String requireType = "";
				try {
					requireType = DataDictionaryCache.getItemCode("SMP0013", row.getCell(10).getStringCellValue());
					smpServiceExtend.setRequireType(requireType);

				} catch (Exception e1) {
					// TODO: handle exception
				}

				try {
					smpServiceExtend.setQmsNo(row.getCell(11).getStringCellValue());
				} catch (Exception e1) {
					// TODO: handle exception
				}

				try {
					String batchNum = DataDictionaryCache.getItemCode("SMP0010", row.getCell(12).getStringCellValue());
					smpServiceExtend.setBatchNum(batchNum);

				} catch (Exception e1) {
					// TODO: handle exception
				}

				// 新增时生产R值
				if ("01".equals(requireType)) {
					String busCode;
					int id = applyServerMapper.getId();
					if (systemNo.length() == 9) {
						busCode = "R000" + "10" + String.format("%06d", id);
					} else {
						busCode = "R" + systemNo + "10" + String.format("%06d", id);
					}
					smpServiceExtend.setBusCode(busCode);

					// 新增时加 申请人，申请时间，开发人员，服务状态
					String applyUser = request.getHeader("userName");
					smpServiceExtend.setProposer(applyUser);
					smpServiceExtend.setDeveloper(applyUser);
					smpServiceExtend.setApplicationTime(new Date());
					smpServiceExtend.setStatus("03");// 03 未发布
				}

//						applyServerExtend.setFunIntr(row.getCell(12).getStringCellValue());
				// 非空校验
				if (StringUtil.isBlank(smpServiceExtend.getRequireType())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[申请类型]无效或为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getTransCode())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[交易码]不能为空");
					return response;
				}
				if (StringUtil.isBlank(smpServiceExtend.getTransName())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[交易名称]不能为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getSystemNo())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[所属系统]不能为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getMsgAgreement())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[报文协议]非法或为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getMsgCode())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[报文编码]非法或为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getMsgCode())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[外部可见]非法或为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getEsbAddr())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[ESB地址]非法或为空");
					return response;
				}

				if (StringUtil.isBlank(smpServiceExtend.getTestAddr())) {
					response.setCode("0001");
					response.setMessage("第" + (i + 1) + "行数据,[测试地址]非法或为空");
					return response;
				}

				// 对ApplyServer进行校验
				// 查询ApplyServer是否有未完成流程
				ApplyServer applyServer = new ApplyServer();
				applyServer.setTransCode(smpServiceExtend.getTransCode());
				applyServer.setSystemNo(smpServiceExtend.getSystemNo());
				applyServer.setRequireType(smpServiceExtend.getRequireType());

				// 调用检验方法
				ResponseMessage<?> check = getServerCheck1(applyServer);
				if ("0001".equals(check.getCode())) {
					response.setCode("0001");
					response.setMessage(check.getMessage());
					return response;
				}

				// 字段表
				// String transCode ="";
				/*
				 * try { transCode = row.getCell(3).getStringCellValue(); }catch (Exception e1)
				 * { // TODO: handle exception }
				 * 
				 * //String systemNo =""; try { systemNo = row.getCell(0).getStringCellValue();
				 * }catch (Exception e1) { // TODO: handle exception }
				 */

				Sheet sheet2 = workbook.getSheet(transCode + "_" + systemNo);
				List<SmpField> smpFieldList = new ArrayList<>();
				if (sheet2 == null) {
					response.setCode("0001");
					response.setMessage("未找到系统[" + systemNo + "]的交易[" + transCode + "]详情sheet页，请检查核对");
					return response;
				}

				if (sheet2 != null && sheet2.getPhysicalNumberOfRows() > 0) {

					// 主表smpService的 功能描述 在第四行 第2列
					smpServiceExtend.setFunIntr(sheet2.getRow(3).getCell(1).getStringCellValue());

					// 主表applyServer的 修改说明 在第五行 第2列
//							applyServerExtend.setRemark(sheet2.getRow(4).getCell(1).getStringCellValue());

//							List<SmpField> smpFieldList = new ArrayList<>();

					String inout = "01";

					for (int j = 7; j < sheet2.getPhysicalNumberOfRows(); j++) {

						Row row2 = sheet2.getRow(j);// 行从第8行开始

						// 没有值得时候跳出循环
						if (row2 == null || row2.getCell(0) == null) {
							continue;
						}

						try {
							String cell0Value = row2.getCell(0).getStringCellValue();
							if ("".equals(cell0Value)) {
								continue;
							} else if ("响应字段".equals(row2.getCell(0).getStringCellValue())) {
								j++;
								inout = "02";
								continue;
							}
						} catch (Exception e) {
							// 不做处理
						}

						SmpField smpField = new SmpField();

						// 序号
						try {
							smpField.setOrderNumber(row2.getCell(0).getStringCellValue());
						} catch (Exception e) {
							try {

								smpField.setOrderNumber(
										Integer.toString(new Double(row2.getCell(0).getNumericCellValue()).intValue()));
							} catch (Exception e1) {
								response.setCode("0001");
								response.setMessage(transCode + "|第" + (j + 1) + "行|[序号]不合法,须为数字");
								return response;
							}
						}

						try {
							smpField.setFieldCode(row2.getCell(1).getStringCellValue());
						} catch (Exception e1) {

						}

						try {
							smpField.setFieldName(row2.getCell(2).getStringCellValue());
						} catch (Exception e1) {

						}

						try {
							smpField.setParentType(row2.getCell(3).getStringCellValue());
						} catch (Exception e1) {

						}

						// 节点类型 01 单节点 02 List节点 03 DATAIL节点
						/*
						 * if("单节点".equals(row2.getCell(4).getStringCellValue())) {
						 * applyField.setNodeType("01"); }else if
						 * ("List节点".equals(row2.getCell(4).getStringCellValue())) {
						 * applyField.setNodeType("02"); }else if
						 * ("DATAIL节点".equals(row2.getCell(4).getStringCellValue())) {
						 * applyField.setNodeType("03"); }
						 */
						try {
							String nodeType = DataDictionaryCache.getItemCode("SMP0017",
									row2.getCell(4).getStringCellValue());
							smpField.setNodeType(nodeType);
						} catch (Exception e1) {

						}

//								applyField.setNodeType(row2.getCell(4).getStringCellValue());

						// 字段类型 01 String 02 Number
						/*
						 * if("String".equals(row2.getCell(5).getStringCellValue())) {
						 * applyField.setFieldType("01"); }else if
						 * ("Number".equals(row2.getCell(5).getStringCellValue())) {
						 * applyField.setFieldType("02"); }
						 */

						try {
							String fieldType = DataDictionaryCache.getItemCode("SMP0018",
									row2.getCell(5).getStringCellValue());
							smpField.setFieldType(fieldType);
						} catch (Exception e1) {

						}

						// 长度
						try {
							smpField.setFieldLength(row2.getCell(6).getStringCellValue());
						} catch (Exception e) {

							if ("01".equals(smpField.getFieldType())) {
								try {
									smpField.setFieldLength(Integer
											.toString(new Double(row2.getCell(6).getNumericCellValue()).intValue()));
								} catch (Exception e1) {
									response.setCode("0001");
									response.setMessage(transCode + "|第" + (j + 1) + "行|[长度]不合法，须为数字");
									return response;
								}
							} else {
								try {
									smpField.setFieldLength(Double.toString(row2.getCell(6).getNumericCellValue()));
								} catch (Exception e1) {

								}
							}
						}

						if ("01".equals(smpField.getFieldType())
								&& (smpField.getFieldLength() == null || "".equals(smpField.getFieldLength()))) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|string类型[长度]不能为空");
							return response;
						}

						// 是否必输 01 是 02 否
						/*
						 * if("是".equals(row2.getCell(7).getStringCellValue())) {
						 * applyField.setFieldRequire("01"); }else if
						 * ("否".equals(row2.getCell(7).getStringCellValue())) {
						 * applyField.setFieldRequire("02"); }
						 */

						try {
							String fieldRequire = DataDictionaryCache.getItemCode("SMP0015",
									row2.getCell(7).getStringCellValue());
							smpField.setFieldRequire(fieldRequire);
						} catch (Exception e1) {

						}

						// 报文结构 01 报文头 02 报文体
						/*
						 * if("报文头".equals(row2.getCell(8).getStringCellValue())) {
						 * applyField.setStruct("01"); }else if
						 * ("报文体".equals(row2.getCell(8).getStringCellValue())) {
						 * applyField.setStruct("02"); }
						 */

						try {
							String struct = DataDictionaryCache.getItemCode("SMP0019",
									row2.getCell(8).getStringCellValue());
							smpField.setStruct(struct);
						} catch (Exception e1) {

						}

						// 输入/输出 01 输入 02 输出
						/*
						 * if("输入".equals(row2.getCell(9).getStringCellValue())) {
						 * applyField.setInOut("01"); }else if
						 * ("输出".equals(row2.getCell(9).getStringCellValue())) {
						 * applyField.setInOut("02"); }
						 */

						// String inOut =DataDictionaryCache.getItemCode("SMP0020",
						// row2.getCell(9).getStringCellValue());

						// applyField.setInOut(inOut);
						smpField.setInOut(inout);

						try {
							smpField.setFieldEdsc(row2.getCell(9).getStringCellValue());
						} catch (Exception e1) {

						}

						// 数据必输项校验

						if (StringUtil.isBlank(smpField.getOrderNumber())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|[序号]不能为空");
							return response;
						}

						if (StringUtil.isBlank(smpField.getFieldCode())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|[字段代码]不能为空");
							return response;
						}
						if (StringUtil.isBlank(smpField.getFieldName())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|[字段名称]不能为空");
							return response;
						}
						if ("01".equals(smpField.getNodeType()) && StringUtil.isBlank(smpField.getFieldType())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|单节点字段[字段类型]不能为空或数据非法");
							return response;
						}
						if (StringUtil.isBlank(smpField.getNodeType())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|[节点类型]不能为空或数据非法");
							return response;
						}
						if (StringUtil.isBlank(smpField.getStruct())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|[报文结构]不能为空或数据非法");
							return response;
						}
						if (StringUtil.isBlank(smpField.getFieldRequire())) {
							response.setCode("0001");
							response.setMessage(transCode + "|第" + (j + 1) + "行|[是否必输]不能为空或数据非法");
							return response;
						}

						smpField.setTransCode(transCode);
						smpField.setSystemNo(systemNo);
						// 添加主表字段
//								smpField.setTransCode(transCode);
//								smpField.setSystemNo(systemNo);
						// 添加字段
//								smpFieldMapper.insertSelective(smpField);
						smpFieldList.add(smpField);
					}
					// 根据申请类型添加修改SmpServer
//							applyServerExtend.setApplyFieldList(applyFieldList);
				}

				if ("01".equals(requireType)) {

					smpServiceMapper.insertSelective(smpServiceExtend);
				} else {
					SmpService smpService1 = smpServiceMapper.selectByPrimaryKey(smpServiceExtend);
					SmpServiceHis smpServiceHis = new SmpServiceHis();
					ObjectUtil.copyBeans(smpService1, smpServiceHis);
					int id = smpServiceHisMapper.getId();
					smpServiceHis.setId(Integer.toString(id));
					smpServiceHisMapper.insertSelective(smpServiceHis);

					smpServiceMapper.updateByPrimaryKeySelective(smpServiceExtend);

					// 插入字段历史表
					SmpField smpField1 = new SmpField();
					smpField1.setTransCode(smpServiceExtend.getTransCode());
					smpField1.setSystemNo(smpServiceExtend.getSystemNo());

					List<SmpField> smpFieldList1 = smpFieldMapper.getFieldListByNoCode(smpField1);

					smpFieldList1.forEach(field -> {
						smpFieldHis smpFieldHis = new smpFieldHis();
						ObjectUtil.copyBeans(field, smpFieldHis);
						smpFieldHis.setServiceHisId(Integer.toString(id));
						fieldHisMapper.insertSelective(smpFieldHis);
					});

					SmpField smpField2 = new SmpField();
					smpField2.setTransCode(transCode);
					smpField2.setSystemNo(systemNo);
					smpFieldMapper.deleteByTransCodeAndSystemNo(smpField2);
				}
				smpFieldList.forEach(field -> {
					smpFieldMapper.insertSelective(field);
				});

			}

			workbook.close();// 关闭资源

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		logger.info(response.getMessage());
		return response;
	}

	public ResponseMessage<?> getServerCheck1(@RequestBody ApplyServer applyServer) {
		ResponseMessage<?> responseMessage = new ResponseMessage<>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("校验成功！");

		// 查询SmpService 新增表有 或者 修改表无 报错
		SmpService smpService = new SmpService();
		smpService.setTransCode(applyServer.getTransCode());
		smpService.setSystemNo(applyServer.getSystemNo());

		int SmpServiceInt = smpServiceMapper.selectByCount(smpService);

		if ("01".equals(applyServer.getRequireType()) && (SmpServiceInt > 0)) { // 新增表有
			responseMessage.setCode("0001");
			responseMessage
					.setMessage("系统[" + applyServer.getSystemNo() + "]中服务[" + applyServer.getTransCode() + "]已存在");
			return responseMessage;
		}

		if (("02".equals(applyServer.getRequireType()) || "03".equals(applyServer.getRequireType()))
				&& (SmpServiceInt == 0)) { // 修改表无
			responseMessage.setCode("0001");
			responseMessage
					.setMessage("系统[" + applyServer.getSystemNo() + "]中服务[" + applyServer.getTransCode() + "]不存在");
			return responseMessage;
		}

		// 查询ApplyServer是否有未完成流程
		int ApplyServerInt = applyServerMapper.selectByCount(applyServer);

		if (ApplyServerInt > 0) {
			responseMessage.setCode("0001");
			responseMessage
					.setMessage("系统[" + applyServer.getSystemNo() + "]中服务[" + applyServer.getTransCode() + "]存在未完成流程");
			return responseMessage;
		}

		return responseMessage;
	}

	/**
	 * 服务历史版本导出
	 * 
	 * @param smpServiceHisExtend
	 * @throws IOException
	 */
	@RequestMapping("/exportHisService")
	public void exportHisService(@RequestBody SmpServiceHisExtend smpServiceHisExtend) throws IOException {
		ResponseMessage<PageInfo<SmpServiceHis>> responseMessage = new ResponseMessage<PageInfo<SmpServiceHis>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
		List<SmpServiceHisExtend> listSmpServiceHis = smpServiceHisMapper.getHisServiceByPage(smpServiceHisExtend);
		response.setContentType("application/octct-stream");
		buildServiceHis(response.getOutputStream(), listSmpServiceHis);
	}

	/**
	 * 服务历史版本导出
	 * 
	 * @param out
	 * @param listSmpServiceHis
	 */
	public void buildServiceHis(OutputStream out, List<SmpServiceHisExtend> listSmpServiceHis) {
		ResponseMessage<PageInfo<SmpServiceHis>> responseMessage = new ResponseMessage<PageInfo<SmpServiceHis>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		//cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		XSSFColor  xssfColor = new XSSFColor(new java.awt.Color(216,228,188));
		cellStyle3.setFillForegroundColor(xssfColor);
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);
		
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_4 = workbook.createCellStyle();
		cellStyle1_4.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_4.setFont(font);

		// 获取工作表名称是Index
		Sheet sheet = workbook.createSheet("目录");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 10 * 256);
		sheet.setColumnWidth(3, 10 * 256);
		sheet.setColumnWidth(4, 40 * 256);
		sheet.setColumnWidth(1, 20 * 256);
		sheet.setColumnWidth(7, 20 * 256);
		sheet.setColumnWidth(8, 40 * 256);
		sheet.setColumnWidth(10, 12 * 256);
		// sheet.setColumnWidth(9, 40*256);

		Row row = sheet.createRow(0);
		Cell cell = row.createCell(0);
		cell.setCellValue("版 本 号：");
		cell.setCellStyle(cellStyle1_4);
		
		cell = row.createCell(1);
		cell.setCellValue(templateversion);
		 row = sheet.createRow(1);
		String[] title = new String[] { "系统编号", "系统名称", "机构号", "交易码", "交易名称", "报文协议", "报文编码", "ESB测试地址", "测试URL",
				"外部可见","http请求方法", "操作类型", "新交易码" };
		for (int i = 0; i < title.length; i++) {
			 cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < listSmpServiceHis.size(); i++) {
			row = sheet.createRow(i + 2);
			Cell systemNoCell = row.createCell(0);
			systemNoCell.setCellStyle(cellStyle1);
			systemNoCell.setCellValue(listSmpServiceHis.get(i).getSystemNo());
			// String systemName =
			// smpSystemMapper.getSystemInfo(listSmpService.get(i).getSystemNo()).getSystemName();
			Cell systemNameCell = row.createCell(1);
			systemNameCell.setCellStyle(cellStyle1);
			systemNameCell.setCellValue(SmpSystemCache.getSystemName(listSmpServiceHis.get(i).getSystemNo()));
			Cell systemOrgCell = row.createCell(2);
			systemOrgCell.setCellStyle(cellStyle1);
			systemOrgCell.setCellValue(listSmpServiceHis.get(i).getSystemOrg());
			// 交易码
			Cell transCodeCell = row.createCell(3);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(listSmpServiceHis.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					listSmpServiceHis.get(i).getTransCode() + "_" + listSmpServiceHis.get(i).getSystemNo() + "!A1");
			hyperlink.setLabel(listSmpServiceHis.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);
			// 交易名称
			Cell transName = row.createCell(4);
			transName.setCellStyle(cellStyle1);
			transName.setCellValue(listSmpServiceHis.get(i).getTransName());
			// 报文协议
			Cell msgAgreement = row.createCell(5);
			msgAgreement.setCellStyle(cellStyle1);
			msgAgreement.setCellValue(listSmpServiceHis.get(i).getMsgAgreement());
			// 报文编码
			Cell msgCodeCell = row.createCell(6);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", listSmpServiceHis.get(i).getMsgCode()));
			// esb地址
			Cell esbAddrCell = row.createCell(7);
			esbAddrCell.setCellStyle(cellStyle1);
			esbAddrCell.setCellValue(listSmpServiceHis.get(i).getEsbAddr());

			// 测试地址
			Cell testAddrCell = row.createCell(8);
			testAddrCell.setCellStyle(cellStyle1);
			testAddrCell.setCellValue(listSmpServiceHis.get(i).getTestAddr());

			// 生产地址
			/*
			 * Cell prodAddrCell = row.createCell(9); prodAddrCell.setCellStyle(cellStyle1);
			 * prodAddrCell.setCellValue(listSmpService.get(i).getProdAddr());
			 */

			// 外部可见
			Cell outShowCell = row.createCell(9);
			outShowCell.setCellStyle(cellStyle1);
			outShowCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", listSmpServiceHis.get(i).getOutShow()));
			Cell httpMethed = row.createCell(10);
			httpMethed.setCellStyle(cellStyle1);
			httpMethed.setCellValue( listSmpServiceHis.get(i).getHttpMethed());
			
			// 外部可见
			Cell operationShowCell = row.createCell(11);
			operationShowCell.setCellStyle(cellStyle1);
			operationShowCell.setCellValue("修改");
			Cell newTransCodeCell = row.createCell(12);
			newTransCodeCell.setCellStyle(cellStyle1);
			newTransCodeCell.setCellValue("");

			// 字段明细
			XSSFSheet sheetTransCode = workbook.createSheet(
					listSmpServiceHis.get(i).getTransCode() + "_" + listSmpServiceHis.get(i).getSystemNo());
			CellRangeAddress regin = new CellRangeAddress(1, 1, 1, 9);

			CellRangeAddress regin1 = new CellRangeAddress(2, 2, 1, 9);
			CellRangeAddress regin2 = new CellRangeAddress(3, 3, 1, 9);

			CellRangeAddress regin3 = new CellRangeAddress(4, 4, 1, 9);

//				CellRangeAddress regin4 = new CellRangeAddress(5, 5, 0, 9);

			sheetTransCode.addMergedRegion(regin);
			sheetTransCode.addMergedRegion(regin1);
			sheetTransCode.addMergedRegion(regin2);
			sheetTransCode.addMergedRegion(regin3);
//				sheetTransCode.addMergedRegion(regin4);

			row = sheetTransCode.createRow(0);

			Cell celltitle = row.createCell(0);
			celltitle.setCellValue("返回索引");
			XSSFHyperlink hyperlink1 = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			// Hyperlink linetoindex = sheetTransCode.addHyperlink(hyperlink);
			hyperlink1.setAddress("目录!D" + (i + 3));
			hyperlink1.setLabel("返回索引");
			celltitle.setHyperlink(hyperlink1);

			// celltitle.setCellStyle(cellStyle);
			row = sheetTransCode.createRow(1);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易码");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpServiceHis.get(i).getTransCode());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}
			row = sheetTransCode.createRow(2);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("交易名称");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpServiceHis.get(i).getTransName());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(3);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("功能简介");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue(listSmpServiceHis.get(i).getFunIntr());
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(4);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_1);
			celltitle.setCellValue("修改说明");
			celltitle = row.createCell(1);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("");
			for (int j = 2; j < 10; j++) {
				celltitle = row.createCell(j);
				celltitle.setCellStyle(cellStyle1_2);
			}

			row = sheetTransCode.createRow(5);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("请求字段");

			row = sheetTransCode.createRow(6);
			String[] fieldsTitle = { "序号", "字段代码", "字段名称", "父节点", "节点类型", "字段类型", "长度", "是否必输", "报文结构", "描述" };
			XSSFCellStyle cellStyle2 = workbook.createCellStyle();

			//cellStyle2.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
			//XSSFColor  xssfColor = new XSSFColor(new java.awt.Color(216,228,188));
			cellStyle2.setFillForegroundColor(xssfColor);
			cellStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
			cellStyle2.setAlignment(HorizontalAlignment.CENTER);

			cellStyle2.setBorderBottom(BorderStyle.THIN);
			cellStyle2.setBorderTop(BorderStyle.THIN);
			cellStyle2.setBorderLeft(BorderStyle.THIN);
			cellStyle2.setBorderRight(BorderStyle.THIN);

			for (int j = 0; j < fieldsTitle.length; j++) {
				 cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			// 输入
			smpFieldHis smpFieldHis = new smpFieldHis();
			smpFieldHis.setServiceHisId(listSmpServiceHis.get(i).getId());
			smpFieldHis.setInOut("01");
			List<smpFieldHis> smpFieldList = smpFieldHisMapper.getHisFieldByHis(smpFieldHis);
			int insize = smpFieldList.size();
			for (int j = 0; j < smpFieldList.size(); j++) {
				smpFieldHis field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + 7);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);
				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

			// 输出
			row = sheetTransCode.createRow(insize + 7);
			celltitle = row.createCell(0);
			celltitle.setCellStyle(cellStyle1_2);
			celltitle.setCellValue("响应字段");

			CellRangeAddress regin5 = new CellRangeAddress(insize + 7, insize + 7, 0, 9);

			sheetTransCode.addMergedRegion(regin5);

			row = sheetTransCode.createRow(insize + 8);
			for (int j = 0; j < fieldsTitle.length; j++) {
				 cell = row.createCell(j);
				cell.setCellStyle(cellStyle2);
				cell.setCellValue(fieldsTitle[j]);

			}

			smpFieldHis.setServiceHisId(listSmpServiceHis.get(i).getId());
			smpFieldHis.setInOut("02");
			smpFieldList = smpFieldHisMapper.getHisFieldByHis(smpFieldHis);
			for (int j = 0; j < smpFieldList.size(); j++) {
				smpFieldHis field = smpFieldList.get(j);
				row = sheetTransCode.createRow(j + insize + 9);
				Cell orderNumberCell = row.createCell(0);
				orderNumberCell.setCellStyle(cellStyle1);
				orderNumberCell.setCellValue(field.getOrderNumber());
				Cell fieldCodeCell = row.createCell(1);
				fieldCodeCell.setCellStyle(cellStyle1);
				fieldCodeCell.setCellValue(field.getFieldCode());
				Cell fieldNameCell = row.createCell(2);
				fieldNameCell.setCellStyle(cellStyle1);
				fieldNameCell.setCellValue(field.getFieldName());
				Cell parentTypeCell = row.createCell(3);
				parentTypeCell.setCellStyle(cellStyle1);
				parentTypeCell.setCellValue(field.getParentType());
				Cell nodeTypeCell = row.createCell(4);
				nodeTypeCell.setCellStyle(cellStyle1);

				nodeTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0017", field.getNodeType()));

				Cell fieldTypeCell = row.createCell(5);
				fieldTypeCell.setCellStyle(cellStyle1);

				fieldTypeCell.setCellValue(dataDictionaryCache.getItemName("SMP0018", field.getFieldType()));

				Cell fieldLengthCell = row.createCell(6);
				fieldLengthCell.setCellStyle(cellStyle1);
				fieldLengthCell.setCellValue(field.getFieldLength());
				Cell fieldRequireCell = row.createCell(7);
				fieldRequireCell.setCellStyle(cellStyle1);

				fieldRequireCell.setCellValue(dataDictionaryCache.getItemName("SMP0015", field.getFieldRequire()));

				Cell structCell = row.createCell(8);
				structCell.setCellStyle(cellStyle1);
				structCell.setCellValue(dataDictionaryCache.getItemName("SMP0019", field.getStruct()));

				/*
				 * Cell inOutCell = row.createCell(9); inOutCell.setCellStyle(cellStyle1);
				 * inOutCell.setCellValue(dataDictionaryCache.getItemName("SMP0020",field.
				 * getInOut()));
				 */
				Cell fieldEdsc = row.createCell(9);
				fieldEdsc.setCellStyle(cellStyle1);
				fieldEdsc.setCellValue(field.getFieldEdsc());
			}

		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}

	@RequestMapping("exportSystemList")
	public void exportSystemList(@RequestBody PageRequest<SmpSystem> pageRequest) {

		String systemNo = pageRequest.getBody().getSystemNo();

		List<IntercatedSystemList> listIntercatedSystem = smpSystemCallMapper.getInteractedSystemListByPage(systemNo);

//	  		List<CallListInfo> callListInfoList = smpSystemCallMapper.getConsumeInfoByQmsNo(pageRequest.getBody());

		ResponseMessage<PageInfo<IntercatedSystemList>> responseMessage = new ResponseMessage<PageInfo<IntercatedSystemList>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);

		// 获取工作表名称是Index
		// Sheet sheet =
		// workbook.createSheet(pageRequest.getBody().getAssociatedRequirement()+"_服务调用");
		Sheet sheet = workbook.createSheet("目录");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 15 * 256);
		sheet.setColumnWidth(1, 30 * 256);
		sheet.setColumnWidth(2, 15 * 256);
		sheet.setColumnWidth(3, 15 * 256);
		sheet.setColumnWidth(4, 20 * 256);
		sheet.setColumnWidth(5, 15 * 256);
		sheet.setColumnWidth(6, 20 * 256);
		sheet.setColumnWidth(7, 15 * 256);
		sheet.setColumnWidth(8, 15 * 256);
		sheet.setColumnWidth(9, 15 * 256);
		sheet.setColumnWidth(10, 50 * 256);

		Row row = sheet.createRow(0);

		String[] title = new String[] { "系统名称", "系统编号", "机构号", "系统负责人", "消费接口数", "服务接口数" };

		for (int i = 0; i < title.length; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < listIntercatedSystem.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell transCodeCell = row.createCell(0);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(listIntercatedSystem.get(i).getSystemName());

			Cell transNameCell = row.createCell(1);
			transNameCell.setCellStyle(cellStyle1);
			transNameCell.setCellValue(listIntercatedSystem.get(i).getSystemNo());

			Cell busCodeCell = row.createCell(2);
			busCodeCell.setCellStyle(cellStyle1);
			busCodeCell.setCellValue(listIntercatedSystem.get(i).getSystemOrg());

			String SystemResponsibleMan = "";
			if (listIntercatedSystem.get(i).getSystemResponsibleMan() != null) {
				SystemResponsibleMan = SmpUserCache
						.getSmpUserName(listIntercatedSystem.get(i).getSystemResponsibleMan());
			}
			Cell regSysCodeCell = row.createCell(3);
			regSysCodeCell.setCellStyle(cellStyle1);
			regSysCodeCell.setCellValue(SystemResponsibleMan);

			Cell regsystemNameCell = row.createCell(4);
			regsystemNameCell.setCellStyle(cellStyle1);
			regsystemNameCell.setCellValue(listIntercatedSystem.get(i).getPubInterfaceNum());

			Cell pubSysCodeCell = row.createCell(5);
			pubSysCodeCell.setCellStyle(cellStyle1);
			pubSysCodeCell.setCellValue(listIntercatedSystem.get(i).getBusInterfaceNum());

		}

		OutputStream out = null;
		try {
			out = response.getOutputStream();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	@RequestMapping("exportInterfaceList")
	public void exportInterfaceList(@RequestBody SmpSystemCall smpSystemCall) {

		List<CallListInfo> callListInfoList = smpSystemCallMapper.getConsumeInfoByQmsNo(smpSystemCall);

		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);

		// 获取工作表名称是Index
		// Sheet sheet =
		// workbook.createSheet(pageRequest.getBody().getAssociatedRequirement()+"_服务调用");
		Sheet sheet = workbook.createSheet("调用列表");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 15 * 256);
		sheet.setColumnWidth(1, 30 * 256);
		sheet.setColumnWidth(2, 15 * 256);
		sheet.setColumnWidth(3, 15 * 256);
		sheet.setColumnWidth(4, 20 * 256);
		sheet.setColumnWidth(5, 15 * 256);
		sheet.setColumnWidth(6, 20 * 256);
		sheet.setColumnWidth(7, 15 * 256);
		sheet.setColumnWidth(8, 15 * 256);
		sheet.setColumnWidth(9, 15 * 256);
		sheet.setColumnWidth(10, 50 * 256);

		Row row = sheet.createRow(0);

		String[] title = new String[] { "交易码", "交易名称", "服务编码(R)", "服务系统编码", "服务系统名称", "消费系统编码", "消费系统名称", "消费方报文格式",
				"消费方字符编码", "服务编码(P)", "访问URL" };

		for (int i = 0; i < title.length; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < callListInfoList.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell transCodeCell = row.createCell(0);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(callListInfoList.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					callListInfoList.get(i).getTransCode() + "_" + callListInfoList.get(i).getRegSysCode() + "!A1");
			hyperlink.setLabel(callListInfoList.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);

			Cell transNameCell = row.createCell(1);
			transNameCell.setCellStyle(cellStyle1);
			transNameCell.setCellValue(callListInfoList.get(i).getTransName());

			Cell busCodeCell = row.createCell(2);
			busCodeCell.setCellStyle(cellStyle1);
			busCodeCell.setCellValue(callListInfoList.get(i).getBusCode());

			Cell regSysCodeCell = row.createCell(3);
			regSysCodeCell.setCellStyle(cellStyle1);
			regSysCodeCell.setCellValue(callListInfoList.get(i).getRegSysCode());

			/*
			 * String regsystemName =
			 * smpSystemMapper.getSystemInfo(callListInfoList.get(i).getRegSysCode())
			 * .getSystemName();
			 */

			String regsystemName = SmpSystemCache.getSystemName(callListInfoList.get(i).getRegSysCode());

			Cell regsystemNameCell = row.createCell(4);
			regsystemNameCell.setCellStyle(cellStyle1);
			regsystemNameCell.setCellValue(regsystemName);

			Cell pubSysCodeCell = row.createCell(5);
			pubSysCodeCell.setCellStyle(cellStyle1);
			pubSysCodeCell.setCellValue(callListInfoList.get(i).getSystemNo());

			String pubsystemName = SmpSystemCache.getSystemName(callListInfoList.get(i).getSystemNo());

			Cell pubsystemNameCell = row.createCell(6);
			pubsystemNameCell.setCellStyle(cellStyle1);
			pubsystemNameCell.setCellValue(pubsystemName);

			Cell msgAgreementCell = row.createCell(7);
			msgAgreementCell.setCellStyle(cellStyle1);
			msgAgreementCell.setCellValue(callListInfoList.get(i).getMsgAgreement());

			Cell msgCodeCell = row.createCell(8);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", callListInfoList.get(i).getMsgCode()));

			Cell pubCodeCell = row.createCell(9);
			pubCodeCell.setCellStyle(cellStyle1);
			pubCodeCell.setCellValue(callListInfoList.get(i).getPubCode());

			Cell proxyPathCell = row.createCell(10);
			proxyPathCell.setCellStyle(cellStyle1);
			proxyPathCell.setCellValue(callListInfoList.get(i).getProxyPath());
		}

		/*
		 * List<String> servers = new ArrayList<String>(); List<SmpService>
		 * smpServiceList = new ArrayList<>(); for(CallListInfo callInfo
		 * :callListInfoList) {
		 * if(!servers.contains(callInfo.getTransCode()+"_"+callInfo.getRegSysCode())) {
		 * servers.add(callInfo.getTransCode()+"_"+callInfo.getRegSysCode());//去重处理
		 * SmpService smpService = new SmpService();
		 * smpService.setSystemNo(callInfo.getRegSysCode());
		 * smpService.setTransCode(callInfo.getTransCode());
		 * smpService.setTransName(callInfo.getTransName());
		 * smpServiceList.add(smpService); } }
		 */
		// buildServiceByCall(workbook, smpServiceList);

		OutputStream out = null;
		try {
			out = response.getOutputStream();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	@RequestMapping("exportSystemCall")
	public void exportSystemCall(@RequestBody List<SmpSystemCallExtend> callListInfoList ) {

	//	List<CallListInfo> callListInfoList = smpSystemCallMapper.getConsumeInfoByQmsNo(smpSystemCall);

		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);

		// 获取工作表名称是Index
		// Sheet sheet =
		// workbook.createSheet(pageRequest.getBody().getAssociatedRequirement()+"_服务调用");
		Sheet sheet = workbook.createSheet("调用列表");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 15 * 256);
		sheet.setColumnWidth(1, 30 * 256);
		sheet.setColumnWidth(2, 15 * 256);
		sheet.setColumnWidth(3, 15 * 256);
		sheet.setColumnWidth(4, 20 * 256);
		sheet.setColumnWidth(5, 15 * 256);
		sheet.setColumnWidth(6, 20 * 256);
		sheet.setColumnWidth(7, 15 * 256);
		sheet.setColumnWidth(8, 15 * 256);
		sheet.setColumnWidth(9, 15 * 256);
		sheet.setColumnWidth(10, 50 * 256);

		Row row = sheet.createRow(0);

		String[] title = new String[] { "交易码", "交易名称", "服务编码(R)", "服务系统编码", "服务系统名称", "消费系统编码", "消费系统名称", "消费方报文格式",
				"消费方字符编码", "服务编码(P)", "访问URL" };

		for (int i = 0; i < title.length; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < callListInfoList.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell transCodeCell = row.createCell(0);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(callListInfoList.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					callListInfoList.get(i).getTransCode() + "_" + callListInfoList.get(i).getRegSysCode() + "!A1");
			hyperlink.setLabel(callListInfoList.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);

			Cell transNameCell = row.createCell(1);
			transNameCell.setCellStyle(cellStyle1);
			transNameCell.setCellValue(callListInfoList.get(i).getTransName());

			Cell busCodeCell = row.createCell(2);
			busCodeCell.setCellStyle(cellStyle1);
			busCodeCell.setCellValue(callListInfoList.get(i).getBusCode());

			Cell regSysCodeCell = row.createCell(3);
			regSysCodeCell.setCellStyle(cellStyle1);
			regSysCodeCell.setCellValue(callListInfoList.get(i).getRegSysCode());

			/*
			 * String regsystemName =
			 * smpSystemMapper.getSystemInfo(callListInfoList.get(i).getRegSysCode())
			 * .getSystemName();
			 */

			String regsystemName = SmpSystemCache.getSystemName(callListInfoList.get(i).getRegSysCode());

			Cell regsystemNameCell = row.createCell(4);
			regsystemNameCell.setCellStyle(cellStyle1);
			regsystemNameCell.setCellValue(regsystemName);

			Cell pubSysCodeCell = row.createCell(5);
			pubSysCodeCell.setCellStyle(cellStyle1);
			pubSysCodeCell.setCellValue(callListInfoList.get(i).getPubSysCode());

			String pubsystemName = SmpSystemCache.getSystemName(callListInfoList.get(i).getPubSysCode());

			Cell pubsystemNameCell = row.createCell(6);
			pubsystemNameCell.setCellStyle(cellStyle1);
			pubsystemNameCell.setCellValue(pubsystemName);

			Cell msgAgreementCell = row.createCell(7);
			msgAgreementCell.setCellStyle(cellStyle1);
			msgAgreementCell.setCellValue(callListInfoList.get(i).getMsgAgreement());

			Cell msgCodeCell = row.createCell(8);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", callListInfoList.get(i).getMsgCode()));

			Cell pubCodeCell = row.createCell(9);
			pubCodeCell.setCellStyle(cellStyle1);
			pubCodeCell.setCellValue(callListInfoList.get(i).getPubCode());

			Cell proxyPathCell = row.createCell(10);
			proxyPathCell.setCellStyle(cellStyle1);
			proxyPathCell.setCellValue(callListInfoList.get(i).getProxyPath());
		}

		/*
		 * List<String> servers = new ArrayList<String>(); List<SmpService>
		 * smpServiceList = new ArrayList<>(); for(CallListInfo callInfo
		 * :callListInfoList) {
		 * if(!servers.contains(callInfo.getTransCode()+"_"+callInfo.getRegSysCode())) {
		 * servers.add(callInfo.getTransCode()+"_"+callInfo.getRegSysCode());//去重处理
		 * SmpService smpService = new SmpService();
		 * smpService.setSystemNo(callInfo.getRegSysCode());
		 * smpService.setTransCode(callInfo.getTransCode());
		 * smpService.setTransName(callInfo.getTransName());
		 * smpServiceList.add(smpService); } }
		 */
		// buildServiceByCall(workbook, smpServiceList);

		OutputStream out = null;
		try {
			out = response.getOutputStream();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	
	
	
	@RequestMapping("exportAllSystemCall")
	public void exportAllSystemCall(
			@RequestBody PageRequest<SmpSystemCallExtend> pageRequest){

	//	List<CallListInfo> callListInfoList = smpSystemCallMapper.getConsumeInfoByQmsNo(smpSystemCall);

		ResponseMessage<PageInfo<SmpService>> responseMessage = new ResponseMessage<PageInfo<SmpService>>();
		responseMessage.setCode("0000");
		responseMessage.setMessage("查询成功！");
		
		List<SmpSystemCallExtend> callListInfoList = smpSystemCallMapper.selectSystemCallByPage(pageRequest.getBody());

		XSSFWorkbook workbook = new XSSFWorkbook();

		XSSFFont font = workbook.createFont();
		font.setBold(true);
		font.getCTFont().addNewB();

		/**
		 * 加背景
		 */
		XSSFCellStyle cellStyle = workbook.createCellStyle();
		cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle.setAlignment(HorizontalAlignment.CENTER);

		cellStyle.setBorderBottom(BorderStyle.THIN);
		cellStyle.setBorderTop(BorderStyle.THIN);
		cellStyle.setBorderLeft(BorderStyle.THIN);
		cellStyle.setBorderRight(BorderStyle.THIN);

		/**
		 * 加背景加粗
		 */
		XSSFCellStyle cellStyle3 = workbook.createCellStyle();
		cellStyle3.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
		cellStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		cellStyle3.setAlignment(HorizontalAlignment.CENTER);

		cellStyle3.setBorderBottom(BorderStyle.THIN);
		cellStyle3.setBorderTop(BorderStyle.THIN);
		cellStyle3.setBorderLeft(BorderStyle.THIN);
		cellStyle3.setBorderRight(BorderStyle.THIN);
		cellStyle3.setFont(font);

		/**
		 * 加边框 居中
		 */
		XSSFCellStyle cellStyle1 = workbook.createCellStyle();
		cellStyle1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1.setBorderBottom(BorderStyle.THIN);
		cellStyle1.setBorderTop(BorderStyle.THIN);
		cellStyle1.setBorderLeft(BorderStyle.THIN);
		cellStyle1.setBorderRight(BorderStyle.THIN);

		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_1 = workbook.createCellStyle();
		cellStyle1_1.setAlignment(HorizontalAlignment.CENTER);
		cellStyle1_1.setBorderBottom(BorderStyle.THIN);
		cellStyle1_1.setBorderTop(BorderStyle.THIN);
		cellStyle1_1.setBorderLeft(BorderStyle.THIN);
		cellStyle1_1.setBorderRight(BorderStyle.THIN);
		cellStyle1_1.setFont(font);
		/**
		 * 加边框 加粗
		 */
		XSSFCellStyle cellStyle1_2 = workbook.createCellStyle();
		cellStyle1_2.setAlignment(HorizontalAlignment.LEFT);
		cellStyle1_2.setBorderBottom(BorderStyle.THIN);
		cellStyle1_2.setBorderTop(BorderStyle.THIN);
		cellStyle1_2.setBorderLeft(BorderStyle.THIN);
		cellStyle1_2.setBorderRight(BorderStyle.THIN);
		// cellStyle1_2.setFont(font);

		// 获取工作表名称是Index
		// Sheet sheet =
		// workbook.createSheet(pageRequest.getBody().getAssociatedRequirement()+"_服务调用");
		Sheet sheet = workbook.createSheet("调用列表");

		// CellStyle cellStyle = workbook.createCellStyle();

		sheet.setColumnWidth(0, 15 * 256);
		sheet.setColumnWidth(1, 30 * 256);
		sheet.setColumnWidth(2, 15 * 256);
		sheet.setColumnWidth(3, 15 * 256);
		sheet.setColumnWidth(4, 20 * 256);
		sheet.setColumnWidth(5, 15 * 256);
		sheet.setColumnWidth(6, 20 * 256);
		sheet.setColumnWidth(7, 15 * 256);
		sheet.setColumnWidth(8, 15 * 256);
		sheet.setColumnWidth(9, 15 * 256);
		sheet.setColumnWidth(10, 50 * 256);

		Row row = sheet.createRow(0);

		String[] title = new String[] { "交易码", "交易名称", "服务编码(R)", "服务系统编码", "服务系统名称", "消费系统编码", "消费系统名称", "消费方报文格式",
				"消费方字符编码", "服务编码(P)", "访问URL" };

		for (int i = 0; i < title.length; i++) {
			Cell cell = row.createCell(i);
			cell.setCellValue(title[i]);
			cell.setCellStyle(cellStyle3);
		}

		for (int i = 0; i < callListInfoList.size(); i++) {
			row = sheet.createRow(i + 1);
			Cell transCodeCell = row.createCell(0);
			transCodeCell.setCellStyle(cellStyle1);
			transCodeCell.setCellValue(callListInfoList.get(i).getTransCode());

			XSSFHyperlink hyperlink = workbook.getCreationHelper().createHyperlink(HyperlinkType.DOCUMENT);
			hyperlink.setAddress(
					callListInfoList.get(i).getTransCode() + "_" + callListInfoList.get(i).getRegSysCode() + "!A1");
			hyperlink.setLabel(callListInfoList.get(i).getTransCode());
			transCodeCell.setHyperlink(hyperlink);

			Cell transNameCell = row.createCell(1);
			transNameCell.setCellStyle(cellStyle1);
			transNameCell.setCellValue(callListInfoList.get(i).getTransName());

			Cell busCodeCell = row.createCell(2);
			busCodeCell.setCellStyle(cellStyle1);
			busCodeCell.setCellValue(callListInfoList.get(i).getBusCode());

			Cell regSysCodeCell = row.createCell(3);
			regSysCodeCell.setCellStyle(cellStyle1);
			regSysCodeCell.setCellValue(callListInfoList.get(i).getRegSysCode());

			/*
			 * String regsystemName =
			 * smpSystemMapper.getSystemInfo(callListInfoList.get(i).getRegSysCode())
			 * .getSystemName();
			 */

			String regsystemName = SmpSystemCache.getSystemName(callListInfoList.get(i).getRegSysCode());

			Cell regsystemNameCell = row.createCell(4);
			regsystemNameCell.setCellStyle(cellStyle1);
			regsystemNameCell.setCellValue(regsystemName);

			Cell pubSysCodeCell = row.createCell(5);
			pubSysCodeCell.setCellStyle(cellStyle1);
			pubSysCodeCell.setCellValue(callListInfoList.get(i).getPubSysCode());


			String pubsystemName = SmpSystemCache.getSystemName(callListInfoList.get(i).getPubSysCode());

			Cell pubsystemNameCell = row.createCell(6);
			pubsystemNameCell.setCellStyle(cellStyle1);
			pubsystemNameCell.setCellValue(pubsystemName);

			Cell msgAgreementCell = row.createCell(7);
			msgAgreementCell.setCellStyle(cellStyle1);
			msgAgreementCell.setCellValue(callListInfoList.get(i).getMsgAgreement());

			Cell msgCodeCell = row.createCell(8);
			msgCodeCell.setCellStyle(cellStyle1);
			msgCodeCell.setCellValue(dataDictionaryCache.getItemName("SMP0004", callListInfoList.get(i).getMsgCode()));

			Cell pubCodeCell = row.createCell(9);
			pubCodeCell.setCellStyle(cellStyle1);
			pubCodeCell.setCellValue(callListInfoList.get(i).getPubCode());

			Cell proxyPathCell = row.createCell(10);
			proxyPathCell.setCellStyle(cellStyle1);
			proxyPathCell.setCellValue(callListInfoList.get(i).getProxyPath());
		}

		/*
		 * List<String> servers = new ArrayList<String>(); List<SmpService>
		 * smpServiceList = new ArrayList<>(); for(CallListInfo callInfo
		 * :callListInfoList) {
		 * if(!servers.contains(callInfo.getTransCode()+"_"+callInfo.getRegSysCode())) {
		 * servers.add(callInfo.getTransCode()+"_"+callInfo.getRegSysCode());//去重处理
		 * SmpService smpService = new SmpService();
		 * smpService.setSystemNo(callInfo.getRegSysCode());
		 * smpService.setTransCode(callInfo.getTransCode());
		 * smpService.setTransName(callInfo.getTransName());
		 * smpServiceList.add(smpService); } }
		 */
		// buildServiceByCall(workbook, smpServiceList);

		OutputStream out = null;
		try {
			out = response.getOutputStream();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			workbook.write(out);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				workbook.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	
	
	
	
	
	
	

}
